import { Navigate } from "react-router-dom";
import useAuthStore from "@/store/auth";
import type { JSX } from "react";

const RequireAuth = ({ children }: { children: JSX.Element }) => {
  const token = useAuthStore((state) => state.token);
  return token ? children : <Navigate to="/login" replace />;
};

export default RequireAuth;
